#ifndef UTILS_H
#define UTILS_H
#include <vector>
#include <string>
#include <map>

using namespace std;

#define CFG_MAX_RAW_DATA_BS "config.MaxRawDataBlockSize"
#define CFG_SUB_VEC_DIM "config.SubVectorDim"
#define CFG_SUB_VEC_NUM "config.SubVectorNum"
#define CFG_REBUILD_COUNT "config.RebuildCount"
#define CFG_RECORD_DIM "config.RecordDim"
#define CFG_QUERY_DATA_BS "config.QueryDataBlockSize"
#define RUN_STOP_POINT "running.StopPoint"
#define RUN_PROCESS "running.Process"
#define RUN_MATCH_POINT "running.MatchPoint"
#define RUN_MATCH_IMAGE "running.MatchImage"
#define RUN_MATCH_VIDEO "running.MatchVideo"

class Config
{
private:
	map<string, int> * _conf;
public :
	Config() {
		_conf = new map<string, int>();
	}

	~Config() {
		delete _conf;
	}
	int GetVal(const string & key) {
		if (_conf->find(key) != _conf->end()) {
			return (*_conf)[key];
		}
		return -1;
	}
	void SetVal(const string & key, int val) {
		(*_conf)[key] = val;
	}
};

vector<string> split(const string & src, string separate_character) {
	vector<string> strs;
	int separate_characterLen = separate_character.size();
	int lastPosition = 0,index = -1;  
	while (-1 != (index = src.find(separate_character,lastPosition)))  
	{  
		strs.push_back(src.substr(lastPosition,index - lastPosition));  
		lastPosition = index + separate_characterLen;  
	}  
	string lastString = src.substr(lastPosition);
	if (!lastString.empty())  
		strs.push_back(lastString);
	return strs;
}

string & trim(string & s) {
	if (s.empty()) {
		return s;
	}
	s.erase(0, s.find_first_not_of(" "));
	s.erase(s.find_last_not_of(" ") + 1);
	return s;
}
#endif